package com.rmuti.programming.ui;

import java.io.IOException;
import java.net.URL;
import java.util.Scanner;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.chula.testinterface.TestResult;
import com.chula.testinterface.TestResultAdapter;

public class ProcessCallServerView extends BaseView {
	private TestResult testResult;

	public ProcessCallServerView(Display display,TestResult testResult) {		
		ImageRegistry registry = new ImageRegistry(display);
		registry.put("bg", ImageDescriptor.createFromFile(ResultScore.class,"../../../../icons/image/header.gif"));
		this.bgImage = registry.get("bg");

		this.display = display;
		this.testResult = testResult;
		this.shell = new Shell(display);
	}

	@Override
	public void display() {
		shell.open();
		shell.setBounds(400, 120, 385, 390);
		createHeaderMenu();				
		createButtomMenu();		
		callServer();
	}

	private void callServer() {
		System.out.println("call server...");
		try {
			URL url = new URL("");
			Scanner sc = new Scanner(url.openStream());
			while(sc.hasNextLine()){
				String line = sc.next();
				System.out.println("line is : "+line);
			}
			sc.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
